<form style="margin: auto">
	<input size="30" type="text" name="q" value="<?=isset($_GET['q']) ? $_GET['q'] : ""?>"/>
	<select name="cadeira">
	 <? echo '<option ' . (isset($_GET['cadeira']) ? ($_GET['cadeira'] == 0 ? ' selected ' : '') : ' selected ') . ' value="0">Todas</option>';
		foreach($cadeiras_info as $item)
		{
			echo '<option ' . (isset($_GET['cadeira']) ? (($_GET['cadeira'] == $item['id']) ? ' selected ' : '') : '') .  'value="' . $item['id'] . '">' . substr($item['link_tit'], 0, 20) . '</option>';
		}
	 ?>
	</select>
	<input type="submit" value="Procurar" />
</form><br /><br />
<table style="margin: auto">
 <caption> Classificados</caption>
 <thead>
  <tr>
   <th><a href="/pesquisar?q=<?=$_GET['q'] ?>&ord=<?=$m_ord == 1 ? 2 : 1 ?>&tipo=2&ind=1&cadeira=<?=$cadeira ?>">Titulo</a></th>
   <th><a href="/pesquisar?q=<?=$_GET['q'] ?>&ord=<?=$m_ord == 1 ? 2 : 1 ?>&tipo=3&ind=1&cadeira=<?=$cadeira ?>">Cadeira</a></th>
   <th><a href="/pesquisar?q=<?=$_GET['q'] ?>&ord=<?=$m_ord == 1 ? 2 : 1 ?>&tipo=4&ind=1&cadeira=<?=$cadeira ?>">Data Adicionado</a></th>
   <th><a href="/pesquisar?q=<?=$_GET['q'] ?>&ord=<?=$m_ord == 1 ? 2 : 1 ?>&tipo=5&ind=1&cadeira=<?=$cadeira ?>">Preço</a></th>
  </tr>
 </thead>
 <tbody>
 <?
  if(isset($classificados[0]))
  {
  	foreach($classificados as $item)
	{
		$output = "<TR>";
      	$output .= "<TD><a href='/classificados/ver/" . $item['id'] . "'> " . $item['titulo'] . "</a></TD>";
      	$output .= "<TD>" . $item['cadeira'] . "</TD>";
      	$output .= "<TD>" . $item['data_ad'] . "</TD>";
      	$output .= "<TD>" . $item['preco'] . " € </TD>";
      	$output .= "</TR>";
      	echo $output;
   	}
   }
 ?>
 </tbody>
 <tfoot>
 </tfoot>
</table>